package hw.test3;

import hw.test1.MyRunnable;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Test {

    public static void main(String[] args) {
        MyRunnable r = new MyRunnable();


        //new Thread(r,"小红").start();
        //new Thread(r,"小明").start();

        //1.
        ExecutorService pool = new ThreadPoolExecutor(
                2,
                5,
                1000,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(3),
                new ThreadPoolExecutor.DiscardOldestPolicy()
        );
        //2.
        pool.execute( r);
        pool.execute( r);
    }
}
